package com.ruoyi.extensionmonitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.extensionmonitor.domain.InfoExtensionMonitorTargetFile;
import com.ruoyi.extensionmonitor.service.IInfoExtensionMonitorTargetFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监控管理附件Controller
 * 
 * @author ruoyi
 * @date 2022-12-05
 */
@RestController
@RequestMapping("/extensionmonitor/extensionmonitorfile")
public class InfoExtensionMonitorTargetFileController extends BaseController
{
    @Autowired
    private IInfoExtensionMonitorTargetFileService infoExtensionMonitorTargetFileService;

    /**
     * 查询监控管理附件列表
     */
    @PreAuthorize("@ss.hasPermi('extensionmonitor:extensionmonitorfile:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoExtensionMonitorTargetFile infoExtensionMonitorTargetFile)
    {
        startPage();
        List<InfoExtensionMonitorTargetFile> list = infoExtensionMonitorTargetFileService.selectInfoExtensionMonitorTargetFileList(infoExtensionMonitorTargetFile);
        return getDataTable(list);
    }

    /**
     * 导出监控管理附件列表
     */
    @PreAuthorize("@ss.hasPermi('extensionmonitor:extensionmonitorfile:export')")
    @Log(title = "监控管理附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoExtensionMonitorTargetFile infoExtensionMonitorTargetFile)
    {
        List<InfoExtensionMonitorTargetFile> list = infoExtensionMonitorTargetFileService.selectInfoExtensionMonitorTargetFileList(infoExtensionMonitorTargetFile);
        ExcelUtil<InfoExtensionMonitorTargetFile> util = new ExcelUtil<InfoExtensionMonitorTargetFile>(InfoExtensionMonitorTargetFile.class);
        util.exportExcel(response, list, "监控管理附件数据");
    }

    /**
     * 获取监控管理附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('extensionmonitor:extensionmonitorfile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoExtensionMonitorTargetFileService.selectInfoExtensionMonitorTargetFileById(id));
    }

    /**
     * 新增监控管理附件
     */
    @PreAuthorize("@ss.hasPermi('extensionmonitor:extensionmonitorfile:add')")
    @Log(title = "监控管理附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoExtensionMonitorTargetFile infoExtensionMonitorTargetFile)
    {
        return toAjax(infoExtensionMonitorTargetFileService.insertInfoExtensionMonitorTargetFile(infoExtensionMonitorTargetFile));
    }

    /**
     * 修改监控管理附件
     */
    @PreAuthorize("@ss.hasPermi('extensionmonitor:extensionmonitorfile:edit')")
    @Log(title = "监控管理附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoExtensionMonitorTargetFile infoExtensionMonitorTargetFile)
    {
        return toAjax(infoExtensionMonitorTargetFileService.updateInfoExtensionMonitorTargetFile(infoExtensionMonitorTargetFile));
    }

    /**
     * 删除监控管理附件
     */
    @PreAuthorize("@ss.hasPermi('extensionmonitor:extensionmonitorfile:remove')")
    @Log(title = "监控管理附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoExtensionMonitorTargetFileService.deleteInfoExtensionMonitorTargetFileByIds(ids));
    }
}
